from django.db import models

class Service(models.Model):
    CATEGORY_CHOICES = (
        ('massage', '按摩'),
        ('spa', 'SPA'),
        ('footcare', '足疗'),
        ('bodycare', '身体护理'),
    )
    
    name = models.CharField(max_length=100, verbose_name='服务名称')
    category = models.CharField(max_length=20, choices=CATEGORY_CHOICES, verbose_name='服务类别')
    description = models.TextField(verbose_name='服务描述')
    duration = models.IntegerField(verbose_name='服务时长(分钟)')  # 例如：60分钟
    price = models.DecimalField(max_digits=10, decimal_places=2, verbose_name='价格')
    is_active = models.BooleanField(default=True, verbose_name='是否启用')
    image = models.URLField(max_length=500, blank=True, verbose_name='服务图片')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    
    class Meta:
        db_table = 'service_item'
        verbose_name = '服务项目'
        verbose_name_plural = verbose_name
    
    def __str__(self):
        return self.name


class Banner(models.Model):
    """轮播图模型"""
    title = models.CharField(max_length=100, verbose_name='标题')
    description = models.CharField(max_length=200, blank=True, verbose_name='描述')
    image = models.URLField(max_length=500, verbose_name='图片URL')
    link = models.URLField(max_length=500, blank=True, verbose_name='链接')
    is_active = models.BooleanField(default=True, verbose_name='是否启用')
    sort_order = models.IntegerField(default=0, verbose_name='排序')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    
    class Meta:
        db_table = 'banner'
        verbose_name = '轮播图'
        verbose_name_plural = verbose_name
        ordering = ['sort_order', '-created_at']
    
    def __str__(self):
        return self.title


class Category(models.Model):
    """服务分类模型"""
    CATEGORY_CHOICES = (
        ('massage', '按摩'),
        ('spa', 'SPA'),
        ('footcare', '足疗'),
        ('bodycare', '身体护理'),
    )
    
    name = models.CharField(max_length=20, choices=CATEGORY_CHOICES, unique=True, verbose_name='分类名称')
    icon = models.URLField(max_length=500, verbose_name='图标URL')
    sort_order = models.IntegerField(default=0, verbose_name='排序')
    is_active = models.BooleanField(default=True, verbose_name='是否启用')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    
    class Meta:
        db_table = 'service_category'
        verbose_name = '服务分类'
        verbose_name_plural = verbose_name
        ordering = ['sort_order']
    
    def __str__(self):
        return self.get_name_display()


class Technician(models.Model):
    """技师模型"""
    name = models.CharField(max_length=50, verbose_name='技师姓名')
    avatar = models.URLField(max_length=500, verbose_name='头像URL')
    rating = models.DecimalField(max_digits=3, decimal_places=1, default=5.0, verbose_name='评分')
    order_count = models.IntegerField(default=0, verbose_name='接单数')
    is_active = models.BooleanField(default=True, verbose_name='是否启用')
    created_at = models.DateTimeField(auto_now_add=True, verbose_name='创建时间')
    updated_at = models.DateTimeField(auto_now=True, verbose_name='更新时间')
    
    class Meta:
        db_table = 'technician'
        verbose_name = '技师'
        verbose_name_plural = verbose_name
    
    def __str__(self):
        return self.name